<!DOCTYPE html>
<html>
  <head>
    <!--META-->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.75">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    <!--CSS-->
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.min.css" />
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.structure.min.css" />
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.theme.min.css" />
    <link rel="stylesheet" href="API/css/mycss.css" />
    <link rel="stylesheet" href="API_RH/css/mycss.css" />
    <link rel="stylesheet" href="css/mycss.css" />

    <!--JS-->
    <script type="text/javascript" src="API/js/jquery.min.js"></script>
    <script type="text/javascript" src="API/js/jquery.mobile.min.js"></script>
    <script type="text/javascript" src="API/js/highcharts.js"></script>
    <script type="text/javascript" src="API/js/modules/exporting.js"></script>
    <!--<script type="text/javascript" src="API/js/jquery.dataTables.min.js"></script>--> 
    <script type="text/javascript" src="include/config.js"></script>
    <script type="text/javascript" src="API/js/fonctions.js"></script>
    <script type="text/javascript" src="API_RH/js/fonctions.js"></script>
    <script type="text/javascript" src="js/fonctions.js"></script>
	
    <script language="javascript" type="text/javascript">
    checkMaintenance();
    checkAuthentification();
	
        ///////////////////
        //BLOCK VARIABLE GLOBAL
        ///////////////////
        var id_page = 6;
        var StockWorker;

        ///////////////////
        //BLOCK FONCTIONS EVENEMENTS
        ///////////////////

        $(document).on('pageinit',function() {
            try {
             // Init commun
                    init_commun();

                    // Init page
                    inputMoisEnCours('dateDepart','dateFin');
                    inputMoisEnCours('dateStatutBegin','dateStatutEnd');
            }
            catch (er) {
                log(0, "ERROR(init_macroprod):" + er.message);
            }
        });
		
        $(document).on('pageshow',function() {
            try {
                    show_commun();
            }
            catch (er) {
                    log(0, "ERROR(show):" + er.message);
            }
        });

        ///////////////////
        //BLOCK FONCTIONS METIER
        ///////////////////
        function AfficherProduction1(p_dateStatutBegin, p_dateStatutEnd) {
            try {
                dateStatutBegin = p_dateStatutBegin;
                dateStatutEnd = p_dateStatutEnd;

                dateBegin = "01/01/1970";
                dateEnd = "01/01/2070";

                if (dateStatutBegin == "") {
                    dateStatutBegin = "01/01/1970";
                }
                if (dateStatutEnd == "") {
                    dateStatutEnd = "01/01/2070";
                }

                var reg = new RegExp("[/]", "g");
                var strDateBegin = dateBegin.replace(reg, '');
                var strDateEnd = dateEnd.replace(reg, '');
                var strDateStatutBegin = dateStatutBegin.replace(reg, '');
                var strDateStatutEnd = dateStatutEnd.replace(reg, '');

                afficherArriveFerme(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd);
            }
            catch (er) {
                log(0, "ERROR(AfficherProduction1):" + er.message);
            }
        }
		
        function AfficherProduction2(p_dateStatutBegin, p_dateStatutEnd) {
            try {
                dateStatutBegin = p_dateStatutBegin;
                dateStatutEnd = p_dateStatutEnd;

                dateBegin = "01/01/1970";
                dateEnd = "01/01/2070";

                if (dateStatutBegin == "") {
                    dateStatutBegin = "01/01/1970";
                }
                if (dateStatutEnd == "") {
                    dateStatutEnd = "01/01/2070";
                }

                var reg = new RegExp("[/]", "g");
                var strDateBegin = dateBegin.replace(reg, '');
                var strDateEnd = dateEnd.replace(reg, '');
                var strDateStatutBegin = dateStatutBegin.replace(reg, '');
                var strDateStatutEnd = dateStatutEnd.replace(reg, '');

                afficherEvolStock(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd);
            }
            catch (er) {
                log(0, "ERROR(AfficherProduction2):" + er.message);
            }
        }
		
        function AfficherProduction3(p_dateStatutBegin, p_dateStatutEnd) {
            try {
                dateStatutBegin = p_dateStatutBegin;
                dateStatutEnd = p_dateStatutEnd;

                dateBegin = "01/01/1970";
                dateEnd = "01/01/2070";

                if (dateStatutBegin == "") {
                    dateStatutBegin = "01/01/1970";
                }
                if (dateStatutEnd == "") {
                    dateStatutEnd = "01/01/2070";
                }

                var reg = new RegExp("[/]", "g");
                var strDateBegin = dateBegin.replace(reg, '');
                var strDateEnd = dateEnd.replace(reg, '');
                var strDateStatutBegin = dateStatutBegin.replace(reg, '');
                var strDateStatutEnd = dateStatutEnd.replace(reg, '');

                afficherEvolStockDom(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd);
            }
            catch (er) {
                log(0, "ERROR(AfficherProduction3):" + er.message);
            }
        }
		
        function AfficherDomaine1(p_dateBegin, p_dateEnd) {
            try {
                dateBegin = p_dateBegin;
                dateEnd = p_dateEnd;
                
                if (dateBegin == "") {
                    dateBegin = "01/01/1970";
                }
                if (dateEnd == "") {
                    dateEnd = "01/01/2070";
                }

                dateStatutBegin = "01/01/1970";
                dateStatutEnd = "01/01/2070";

                var reg = new RegExp("[/]", "g");
                var strDateBegin = dateBegin.replace(reg, '');
                var strDateEnd = dateEnd.replace(reg, '');
                var strDateStatutBegin = dateStatutBegin.replace(reg, '');
                var strDateStatutEnd = dateStatutEnd.replace(reg, '');

                afficherDomaine(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd);
            }
            catch (er) {
                log(0, "ERROR(init):" + er.message);
            }
        }
		
        function AfficherDomaine2(p_dateBegin, p_dateEnd) {
            try {
                dateBegin = p_dateBegin;
                dateEnd = p_dateEnd;
                
                if (dateBegin == "") {
                    dateBegin = "01/01/1970";
                }
                if (dateEnd == "") {
                    dateEnd = "01/01/2070";
                }

                dateStatutBegin = "01/01/1970";
                dateStatutEnd = "01/01/2070";

                var reg = new RegExp("[/]", "g");
                var strDateBegin = dateBegin.replace(reg, '');
                var strDateEnd = dateEnd.replace(reg, '');
                var strDateStatutBegin = dateStatutBegin.replace(reg, '');
                var strDateStatutEnd = dateStatutEnd.replace(reg, '');

                afficherDomainePie(strDateBegin, strDateEnd, strDateStatutBegin, strDateStatutEnd);
            }
            catch (er) {
                log(0, "ERROR(init):" + er.message);
            }
        }

        function afficherArriveFerme(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var tab = new Array();
                tab = getTabProd("Ferm\351", "", p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                tabDataUp = new Array();
                
                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][1].substring(8, 10);
                    mois = String((tab[indice][1].substring(5, 7)) - 1);
                    annee = tab[indice][1].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][0]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }
                
                tabDataUp[tabDataUp.length] = {
                    name: 'Toc ferm\351',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getTabProd("R\351ception", "", p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);
                
                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][1].substring(8, 10);
                    mois = String((tab[indice][1].substring(5, 7)) - 1);
                    annee = tab[indice][1].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][0]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Toc arriv\351',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getUo(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), (parseFloat(tab[indice][1])*30));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Uo',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getUoConsolide(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), (parseFloat(tab[indice][1]) * 30));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Uo consolid\351',
                    data: tabDataMiddle
                };

                afficheGraph(tabDataUp);
            }
            catch (er) {
                log(0, "ERROR(afficherBoard):" + er.message);
            }
        }

        function afficherDomaine(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var tab = new Array();
                tab = getTabDomaine(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                var tmp = new Array();
                oldDomaine = "";
                newDomaine = "";
                
                var tabDomaine = new Array();

                for (var indice in tab) {
                    domaine = tab[indice][0];
                    newDomaine = domaine;
                    date = tab[indice][1];
                    nombre = tab[indice][2];
                    if (oldDomaine != newDomaine) {
                        tabDomaine[oldDomaine] = tmp;
                        tmp = new Array();
                        oldDomaine = newDomaine;
                    }
                    tmp[tmp.length] = new Array(date, nombre);
                }

                tabDataUp = new Array();

                for (var indiceDom in tabDomaine) {

                    if ((indiceDom != " N/A")&(indiceDom != "")){
                        tabDataMiddle = new Array();
                        tabDataDown = new Array();

                        for (var indice in tabDomaine[indiceDom]) {
                            jour = tabDomaine[indiceDom][indice][0].substring(8, 10);
                            mois = String((tabDomaine[indiceDom][indice][0].substring(5, 7)) - 1);
                            annee = tabDomaine[indiceDom][indice][0].substring(0, 4);
                            tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tabDomaine[indiceDom][indice][1]));
                            tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                        }

                        tabDataUp[tabDataUp.length] = {
                            name: indiceDom,
                            data: tabDataMiddle
                        };
                    }
                }

                afficheGraphDomaine(tabDataUp);
                
            }
            catch (er) {
                log(0, "ERROR(afficherDomaine):" + er.message);
            }
        }

        function afficherDomainePie(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var tab = new Array();
                tab = getTabDomainePie(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                affichePieTag(tab);
            }
            catch (er) {
                log(0, "ERROR(afficherDomainePie):" + er.message);
            }
        }

        function afficherEvolStock(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                tabDataUp = new Array();
            
                var tab = new Array();
                tab = getTabEvolEnCours(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);
                tab = tab.splice(1, tab.length-1);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][1]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Tocs en cours',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getTabEvolBF(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);
                tab = tab.splice(1, tab.length - 1);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][1]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Tocs bient\364t ferm\351s',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getTabEvolBacklog(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);
                tab = tab.splice(1, tab.length - 1);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][1]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Tocs en backlog',
                    data: tabDataMiddle
                };

                var tab = new Array();
                tab = getCharges(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd);

                tabDataMiddle = new Array();
                tabDataDown = new Array();

                for (var indice in tab) {
                    jour = tab[indice][0].substring(8, 10);
                    mois = String((tab[indice][0].substring(5, 7)) - 1);
                    annee = tab[indice][0].substring(0, 4);
                    tabDataDown = new Array(Date.UTC(annee, mois, jour), parseInt(tab[indice][1]));
                    tabDataMiddle[tabDataMiddle.length] = tabDataDown;
                }

                tabDataUp[tabDataUp.length] = {
                    name: 'Charges \351quipe',
                    data: tabDataMiddle
                };

                afficheGraphEvolStock(tabDataUp);
            }
            catch (er) {
                log(0, "ERROR(afficherEvolStock):" + er.message);
            }
        }
        
        function afficherEvolStockDom(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strhtml = "";

                /* Vérifie si les Web Workers sont supportés */
                if (window.Worker) {
                    strhtml += "<IMG SRC=\"API/img/loading.gif\" ALT=\"Chargement\" TITLE=\"Chargement\">";
                    $('#divProd').html(strhtml);

                    StockWorker = initWorker("WorkerEvolStock.js", "afficherEvolStockDom_retour");

                    var json_param = {
                        dateBegin : p_dateBegin,
                        dateEnd : p_dateEnd,
                        dateStatutBegin : p_dateStatutBegin,
                        dateStatutEnd : p_dateStatutEnd
                    }

                    StockWorker.postMessage(new WorkerMessage('calcule', json_param)); 
                }
                else {
                    $('#divEvolStock').html("Les Web Workers ne sont pas support&eacute;s par votre navigateur. R&eacute;essayez avec IE10 : <a href=\"http://ie.microsoft.com/testdrive\">t&eacute;l&eacute;chargez la derni&egrave;re Platform Preview d'IE10 </a>");
                }

            }
            catch (er) {
                log(0, "ERROR(afficherEvolStockDom):" + er.message);
            }
        }

        function afficherEvolStockDom_retour(p_message) {
            try {
                switch (p_message.cmd) {
                    case 'avancement':
                        var percent = p_message.parameter;
                        $('#divProd').html("<p>Avancement de la t&acirc;che...<strong><label id=\"labelProgress\">"+percent+"</label>%</strong><progress id=\"avancementProd\" value=\""+percent+"\" max=\"100\"></progress><img src=\"API/img/loading.gif\" alt=\"loading\" style=\"vertical-align:middle;\" /><br><a href=\"javascript:terminateStockWorker();\">Annuler</a></p>").trigger('create');
                        break;
                    case 'resultats':
                        terminateWorker(StockWorker);
                        afficheGraphEvolStockDom(p_message.parameter);
                    break;
                    case 'stats':
                        $('#statProd').html("Génération de l'analyse en "+p_message.parameter+".");
                    break;
                }
            }
            catch (er) {
                log(0, "ERROR(afficherEvolStockDom_retour):" + er.message);
            }
        }
	
        ///////////////////
        //BLOCK FONCTIONS AFFICHAGE
        ///////////////////
        function afficheGraph(tabDataUp) {
            var chart;

            chart = new Highcharts.Chart({
                exporting: {
                    url: 'http://export.highcharts.com',
                    filename: 'Macro-production',
                    width: 1600
                },
                chart: {
                    renderTo: 'divProd',
                    type: 'spline'
                },
                title: {
                    text: 'Macro-production'
                },
                subtitle: {
                    text: 'By FRO'
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: { // don't display the dummy year
                        month: '%e. %b',
                        year: '%b'
                    }
                },
                yAxis: {
                    title: {
                        text: 'TOC (u)'
                    },
                    min: 0
                },
                tooltip: {
                    formatter: function() {
                    if ((this.series.name == "Uo") | (this.series.name == "Uo consolid\351")) {
                            return '<b>' + this.series.name + '</b><br/>' +
					        Highcharts.dateFormat('%e. %b', this.x) + ': ' + getRound((this.y / 30), 3) + 'Uo';
                        } else {
                            return '<b>' + this.series.name + '</b><br/>' +
					        Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + 'toc(s)';
                        }
                    }
                    
                },
                series: tabDataUp
            });
        }

        function afficheGraphDomaine(tabDataUp) {
            var chart;

            chart = new Highcharts.Chart({
                exporting: {
                    url: 'http://export.highcharts.com',
                    filename: 'Macro-production',
                    width: 1600
                },
                chart: {
                    renderTo: 'divProd',
                    type: 'spline'
                },
                title: {
                    text: 'Macro-production'
                },
                subtitle: {
                    text: 'By FRO'
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: { // don't display the dummy year
                        month: '%e. %b',
                        year: '%b'
                    }
                },
                yAxis: {
                    title: {
                        text: 'TOC (u)'
                    },
                    min: 0
                },
                tooltip: {
                    formatter: function() {
                        return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + ' toc(s)';
                    }
                },
                series: tabDataUp
            });
        }

        function affichePieTag(tabData) {
            var tab = tabData;
        
            var chart;

            $(document).ready(function() {
                chart = new Highcharts.Chart({
                    exporting: {
                        url: 'http://export.highcharts.com',
                        filename: 'domaineRepartition',
                        width: 1600
                    },
                    chart: {
                    renderTo: 'divProd',
                        plotBackgroundColor: null,
                        plotBorderWidth: null,
                        plotShadow: false
                    },
                    title: {
                        text: 'R\351partition des domaines'
                    },
                    tooltip: {
                        formatter: function() {
                            return '<b>' + this.point.name + '</b>: ' + this.y + '%';
                        }
                    },
                    plotOptions: {
                        pie: {
                            allowPointSelect: true,
                            cursor: 'pointer',
                            dataLabels: {
                                enabled: true,
                                color: '#000000',
                                connectorColor: '#000000',
                                formatter: function() {
                                    return '<b>' + this.point.name + '</b>: ' + this.y + '%';
                                }
                            }
                        }
                    },
                    series: [{
                        type: 'pie',
                        name: 'Browser share',
                        data: tab
                    }]
                    });
                });
            }

        function afficheGraphEvolStock(tabDataUp) {
            var chart;

            chart = new Highcharts.Chart({
                exporting: {
                    url: 'http://export.highcharts.com',
                    filename: 'Evolution des stocks',
                    width: 1600
                },
                chart: {
                    renderTo: 'divProd',
                    type: 'spline'
                },
                title: {
                    text: 'Evolution des stocks'
                },
                subtitle: {
                    text: 'By FRO'
                },
                xAxis: {
                    type: 'datetime',
                    dateTimeLabelFormats: { // don't display the dummy year
                        month: '%e. %b',
                        year: '%b'
                    }
                },
                yAxis: {
                    title: {
                        text: 'TOC (u)'
                    },
                    min: 0
                },
                tooltip: {
                    formatter: function() {
                        return '<b>' + this.series.name + '</b><br/>' + Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + ' toc(s)';
                    }
                },
                series: tabDataUp
            });
        }

        function afficheGraphEvolStockDom(tabDataUp) {
            var chart;

            $(document).ready(function() {
                    chart = new Highcharts.Chart({
                            exporting: {
                                    url: 'http://export.highcharts.com',
                                    filename: 'Evolution des stocks',
                                    width: 1600
                            },
                            chart: {
                                    renderTo: 'divProd',
                                    type: 'spline'
                            },
                            title: {
                                    text: 'Evolution des stocks'
                            },
                            subtitle: {
                                    text: 'By FRO'
                            },
                            xAxis: {
                                    type: 'datetime',
                                    dateTimeLabelFormats: { // don't display the dummy year
                                            month: '%e. %b',
                                            year: '%b'
                                    }
                            },
                            yAxis: {
                                    title: {
                                            text: 'TOC (u)'
                                    },
                                    min: 0
                            },
                            plotOptions: {
                                    series: {
                                            marker: {
                                                    enabled: false,
                                                    states: {
                                                            hover: {
                                                                    enabled: true,
                                                                    radius: 3
                                                            }
                                                    }
                                            }
                                    }
                            },
                            tooltip: {
                                    formatter: function() {
                                            return '<b>' + this.series.name + '</b><br/>' +
                                                            Highcharts.dateFormat('%e. %b', this.x) + ': ' + this.y + ' toc(s)';
                                    }
                            },
                            series: tabDataUp
                    });
            });
        }
        
        ///////////////////
        //BLOCK FONCTIONS TECHNIQUES
        ///////////////////
        function terminateStockWorker() {
            try {
                terminateWorker(StockWorker);
                $('#divProd').html("Analyse annul&eacute;e");
            }
            catch (er) {
                log(0, "ERROR(terminateStockWorker):" + er.message);
            }
        }
    
        ///////////////////
        //BLOCK FONCTIONS BD
        ///////////////////

        function getTabProd(statut, user, p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getProdByDateByStatutUser.php?milis=" + getMilise() + "&statut=" + statut + "&user=" + user + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd; 

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        returns[returns.length] = tempSubTab.slice(0, tempSubTab.length - 1);
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabProd):" + er.message);
            }
        }

        function getTabDomaine(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getDomaine.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        returns[returns.length] = tempSubTab.slice(0, tempSubTab.length - 1);
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabDomaine):" + er.message);
            }
        }

        function getTabDomainePie(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getDomainePie.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd + "&resp=";

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabProd):" + er.message);
            }
        }

        function getTabEvolEnCours(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getEvolEncours.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabEvolEnCours):" + er.message);
            }
        }
		
        function getTabEvolDomEnCours(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd, p_domaine) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getEvolDomEncours.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd + "&domaine=" + p_domaine;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabEvolDomEnCours):" + er.message);
            }
        }

        function getTabEvolBF(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getEvolBF.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabEvolBF):" + er.message);
            }
        }
		
        function getTabEvolDomBF(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd, p_domaine) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getEvolDomBF.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd + "&domaine=" + p_domaine;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabEvolDomBF):" + er.message);
            }
        }

        function getTabEvolBacklog(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getEvolBacklog.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getTabEvolBacklog):" + er.message);
            } finally {
                delete xhr_object;
            }
        }

        function getUo(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();

                xhr_object = new AJ();

                var url = "phpsql/mysql_getUOByDate.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getUo):" + er.message);
            }
        }

        function getUoConsolide(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();
                xhr_object = new AJ();

                if (p_dateBegin == "01011970") {
                    p_dateBegin = p_dateStatutBegin;
                }
                if (p_dateStatutBegin == "01011970") {
                    p_dateStatutBegin = p_dateBegin;
                }

                if (p_dateEnd == "01012070") {
                    p_dateEnd = p_dateStatutEnd;
                }
                if (p_dateStatutEnd == "01012070") {
                    p_dateStatutEnd = p_dateEnd;
                }

                var url = "phpsql/mysql_getUOConsoByDate.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getUoConsolide):" + er.message);
            }
        }

        function getCharges(p_dateBegin, p_dateEnd, p_dateStatutBegin, p_dateStatutEnd) {
            try {
                var strResponse = "";
                var returns = new Array();
                var tempTab = new Array();
                var tempSubTab = new Array();
                xhr_object = new AJ();

                if (p_dateBegin == "01011970") {
                    p_dateBegin = p_dateStatutBegin;
                }
                if (p_dateStatutBegin == "01011970") {
                    p_dateStatutBegin = p_dateBegin;
                }

                if (p_dateEnd == "01012070") {
                    p_dateEnd = p_dateStatutEnd;
                }
                if (p_dateStatutEnd == "01012070") {
                    p_dateStatutEnd = p_dateEnd;
                }

                var url = "phpsql/mysql_getChargeByDate.php?milis=" + getMilise() + "&dateBegin=" + p_dateBegin + "&dateEnd=" + p_dateEnd + "&dateStatutBegin=" + p_dateStatutBegin + "&dateStatutEnd=" + p_dateStatutEnd;

                xhr_object.open("GET", url, false);
                xhr_object.send(null);
                if (xhr_object.readyState == 4) {
                    strResponse = xhr_object.responseText;
                } else {
                    strResponse = "ERROR";
                }

                tempTab = strResponse.split("\n");

                for (var indice in tempTab) {
                    tempSubTab = tempTab[indice].split("&");
                    if (tempSubTab.length > 1) {
                        tab = new Array(tempSubTab[0], parseFloat(tempSubTab[1]));
                        returns[returns.length] = tab;
                    }
                }

                delete xhr_object;

                return returns;
            }
            catch (er) {
                log(0, "ERROR(getCharges):" + er.message);
            }
        }


        
    </script>
	
  </head>
  <body>
    
	<!-- page -->
	<div data-role="page" data-title="Titre">
	
		<!-- /panel -->
		<div data-role="panel" id="mypanel" data-display="overlay" data-position="left">

		</div>
		<!-- /panel -->
	
		<!-- header -->
		<div data-role="header" data-position="fixed">
			<a href="#mypanel" data-role="button" data-icon="home" data-iconpos="notext">home</a>
			<h1 id="id_titre">titre</h1>
			<a href="javascript:window.location = ('./page_contact.html?mili='+getMilise());" data-role="button" data-icon="info" data-iconpos="notext">Contact</a>
		</div>
		<!-- /header -->

		<!-- content -->
		<div data-role="content" id="main_content">
		
			<div data-role="collapsible" data-collapsed="false" data-mini="true">
				<h3>Votre recherche</h3>
				
				<FORM method="post" id="formulaire" action="#">
					<span class="sansserif">Pour les tickets cr&eacute;&eacute;s entre</span>
					<input type="text" id="dateDepart" name="dateDepart" /><span class="sansserif">(DD/MM/YYYY) et</span>
					<input type="text" id="dateFin" name="dateFin" /> <span class="sansserif">(DD/MM/YYYY)</span>
					<a href="javascript:inputMoisEnCours('dateDepart','dateFin');" data-role="button" data-inline="true" data-mini="true" title="Mois en cours">M</a>
					<br />
					<a class="sansserif" href="javascript:AfficherDomaine1(document.forms.formulaire.dateDepart.value, document.forms.formulaire.dateFin.value);" id="A5">L'arriv&eacute;e par domaine</a>
					-
					<a class="sansserif" href="javascript:AfficherDomaine2(document.forms.formulaire.dateDepart.value, document.forms.formulaire.dateFin.value);" id="A5">La r&eacute;partition par domaine</a>
					<br />
					<br />
					<span class="sansserif">Pour les tickets avec date de statut entre</span>
					<input type="text" id="dateStatutBegin" name="dateStatutBegin" /><span class="sansserif">(DD/MM/YYYY) et</span>
					<input type="text" id="dateStatutEnd" name="dateStatutEnd" /> <span class="sansserif">(DD/MM/YYYY)</span>
					<a href="javascript:inputMoisEnCours('dateStatutBegin','dateStatutEnd');" data-role="button" data-inline="true" data-mini="true" title="Mois en cours">M</a>	
					<br />
					<a class="sansserif" href="javascript:AfficherProduction1(document.forms.formulaire.dateStatutBegin.value, document.forms.formulaire.dateStatutEnd.value);" id="A5">La production</a>
					-
					<a class="sansserif" href="javascript:AfficherProduction2(document.forms.formulaire.dateStatutBegin.value, document.forms.formulaire.dateStatutEnd.value);" id="A5">Le stock</a>
					-
					<a class="sansserif" href="javascript:AfficherProduction3(document.forms.formulaire.dateStatutBegin.value, document.forms.formulaire.dateStatutEnd.value);" id="A5">Le stock par domaine</a>
					<br />
					<br />
				</FORM>
				
			</div>
			
			<div data-role="collapsible" data-collapsed="false" data-mini="true" id='content_result'>
				<h3>Affichage</h3>
                                <div id="divProd">Pas de r&eacute;sultat.</div>
                                <label id="statProd"></label>
			</div>
			
		</div>
		<!-- /content -->
		
		<!-- footer -->
		<div data-role="footer" data-position="fixed">
			<a data-role="button" data-icon="search" data-iconpos="notext" class="ui-btn-left" href="javascript:window.location = ('./page_faq.html?mili='+getMilise());">FAQ</a>
			<h1 id="id_affichageUser">User</h1>
			<a data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right" href="javascript:window.location = ('./page_sortie.html?mili='+getMilise());">Logout</a>
		</div>
		<!-- /footer -->
		
	</div>
	<!-- /page -->
</body>
</html>	